package com.cn

import com.cn.model.Users
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import java.time.LocalDateTime
import javax.annotation.Resource

data class AA(var id: Int, var nome: String)

fun main(args: Array<String>) {
    val listOf = listOf(1, 2, 3, 4, 5)
    println(listOf)
    println(listOf.map { it - 1 })

    val listOf1 = listOf("aaaa", "bbb", "ccc", "ddd")
    println(listOf1)
    println(listOf1.map { it -> it.substring(0, 1) })

    val mutableListOf = mutableListOf<AA>()
    for (i in 1..5) {
        mutableListOf.add(AA(i, "bb$i"))
    }
    println(mutableListOf)
//    生成新列表
    println(mutableListOf.map { AA(it.id * 2, it.nome) })
//    修改原列表
    println(mutableListOf.forEach { aa: AA -> aa.id *= 2 })
    println(mutableListOf)


}

val kk: (Int) -> Int = { it * 2 }